package com.aaa.controller.sds;

import com.aaa.entity.LayData;
import com.aaa.entity.MyPage;
import com.aaa.entity.sds.TSdsRecord;
import com.aaa.entity.sds.TjMessage;
import com.aaa.entity.sds.Ttongji;
import com.aaa.service.sds.TSdsRecordService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * (TSdsRecord)表控制层
 *
 * @author ZXJ
 * @since 2022-10-31 15:58:16
 */
@RestController
@RequestMapping("tSdsRecord")
public class TSdsRecordController {
    /**
     * 服务对象
     */
    @Autowired
    private TSdsRecordService tSdsRecordService;

    /**
     * 分页查询所有题目
     * @param myPage
     * @param tSdsRecord
     * @return
     */
    @RequestMapping("/queryAllRecord")
    @ResponseBody
    public LayData queryAllRecord(MyPage myPage, TSdsRecord tSdsRecord){
        PageInfo pageInfo =tSdsRecordService.queryAllRecord(myPage,tSdsRecord);
        System.out.println("pageInfo = " + pageInfo);
        return new LayData(pageInfo);
    }

    /**
     * 做题详情
     * @param id
     * @param myPage
     * @return
     */
    @GetMapping("{id}")
    public LayData getDetailData(@PathVariable Integer id, MyPage myPage){
        return new LayData(tSdsRecordService.getDetailMsg(myPage,id));
    }

    /**
     *  将记录添加到数据库
     * @param tSdsRecord
     * @return
     */
    @PostMapping("addrecord")
    public LayData addrecord(TSdsRecord tSdsRecord){
        return new LayData(tSdsRecordService.insertRecord(tSdsRecord));
    }

    @GetMapping("checkrecord")
    public LayData checkUser(TSdsRecord tSdsRecord){
        return new LayData(tSdsRecordService.checkrecord(tSdsRecord));
    }

    @GetMapping("/tj")
    @ResponseBody
    public LayData getTongji(MyPage myPage,TjMessage tjMessage){
        //List<TjMessage> tjData = tSdsRecordService.getTjData(myPage,tjMessage);
        PageInfo tjData = tSdsRecordService.getTjData(myPage, tjMessage);
        System.out.println("_____________________________");
        System.out.println("tjData = " + tjData);
        return new LayData(tSdsRecordService.getTjData(myPage,tjMessage));
    }

    @GetMapping("/tj2")
    public LayData getTongji2(MyPage myPage, Ttongji ttongji){
        PageInfo tjData2 = tSdsRecordService.getTjData2(myPage, ttongji);
        System.out.println("tjData2--------------------------------------------- = " + tjData2);
        return new LayData(tSdsRecordService.getTjData2(myPage,ttongji));
    }
}

